home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 4.2 KB | 151 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PatFrame.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef PATFRAME_H
- #include "PatFrame.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWCONTXT_H
- #include "FWContxt.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWCOLOR_H
- #include "FWColor.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawframes
- #endif
-
- FW_DEFINE_AUTO(CPatternFrame)
-
- //========================================================================================
- // CLASS CPatternFrame
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::CPatternFrame
- //----------------------------------------------------------------------------------------
-
- CPatternFrame::CPatternFrame(Environment* ev, ODFrame* odFrame, FW_CPresentation* presentation, CDrawPart *drawPart) :
- CFloatingWindowFrame(ev, odFrame, presentation, drawPart),
- fGrid(2, 6, FW_CPoint(FW_IntToFixed(2), FW_IntToFixed(2)), FW_CPoint(kPatternCellSize, kPatternCellSize), FW_kFixedPos1)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::~CPatternFrame
- //----------------------------------------------------------------------------------------
-
- CPatternFrame::~CPatternFrame()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::Draw
- //----------------------------------------------------------------------------------------
-
- void CPatternFrame::Draw(Environment* ev, ODFacet* odFacet, ODShape* invalidShape)
- {
- FW_CViewContext vc(ev, this, odFacet, invalidShape);
- vc.SetMapping(fMapping);
-
- EraseBackground(ev, vc);
-
- // ----- Draw the grid -----
- fGrid.DrawGridBorders(vc);
-
- // ----- Draw each color -----
- FW_CRect rect;
- FW_CRectShape rectShape(FW_kZeroRect, FW_kFill);
- for (unsigned long index = 0; index < 12; index++)
- {
- fGrid.GetCellInterior(index, rect);
- rectShape.SetRectangle(rect);
- rectShape.GetStyle().SetPattern(fDrawPart->GetPattern(index));
- rectShape.Render(vc);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::DoMouseDown
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CPatternFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_CPoint where = theMouseEvent.GetLogicalMousePosition(ev, fMapping);
-
- unsigned long patIndex;
- if (fGrid.FindCell(where, patIndex))
- {
- if (theMouseEvent.IsCopyModifier(ev))
- fDrawPart->SetFramePattern(ev, patIndex);
- else
- fDrawPart->SetFillPattern(ev, patIndex);
- }
-
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- // CPatternFrame::FacetAdded
- //----------------------------------------------------------------------------------------
- // When ODWindow moves back to ODFrame we will be able to move this code
- // back to the constructor
-
- void CPatternFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- // ----- Call inherited first -----
- CFloatingWindowFrame::FacetAdded(ev, facet, facetCount);
-
- // ----- Resize my Window -----
- FW_CRect gridRect;
- fGrid.GetExteriorGridRect(gridRect);
- gridRect.Inset(-FW_IntToFixed(2), -FW_IntToFixed(2));
- FW_CPoint windowSize(gridRect.Width(), gridRect.Height());
- GetWindow(ev)->SetWindowSize(ev, windowSize);
- }
-
-